package com.lqa.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lqa.mapper.EbProductCategoryMapper;
import com.lqa.mapper.EbProductMapper;
import com.lqa.model.EbProduct;
import com.lqa.model.EbProductCategory;
import com.sun.javafx.collections.MappingChange;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class EbProductCategoryService {
    @Autowired
    private EbProductMapper ebProductMapper;
    @Autowired
    private EbProductCategoryMapper ebProductCategoryMapper;
    public Page<EbProduct> findProductByCate(int psize,int pageSize,int epcId){
        Page<EbProduct> page= new Page(psize,pageSize);
        return ebProductMapper.selectPage(page,new QueryWrapper<EbProduct>()
        .eq("epc_child_id",epcId));
    }
    public Map<String, List<EbProductCategory>> selectBigAndSmallCate(){
        List<EbProductCategory> bigCates = ebProductCategoryMapper.selectBigCate();
        List<EbProductCategory> smallCates = ebProductCategoryMapper.selectSmallCate();
        Map<String, List<EbProductCategory>> cateMap = new HashMap<>();
        cateMap.put("bigs", bigCates);
        cateMap.put("smalls", smallCates);
        return cateMap;
    }
}
